<template>
  <div>
    购物车模块中的num
    <br>
    <button @click="itemAddNum(50)">购物车+</button>
    {{ cartNum }}
    {{ aa }}
    <hr>
    user模块中的num
    <button @click="userAddNum(200)">user里的+</button>
    <br>
    {{ userNum }}
  </div>
</template>

<script>
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
export default {
  created () {
    /* this.FETCH_CATES({
      a: 10
    }) */
    this.fetchCates({
      a: 10
    })
  },
  methods: {
    // ...mapMutations('cart', ['ADD_NUM']),
    ...mapMutations('cart', {
      itemAddNum: 'ADD_NUM'
    }),
    ...mapMutations('user', {
      userAddNum: 'ADD_NUM'
    }),
    // ...mapActions('cart', ['FETCH_CATES'])
    ...mapActions('cart', {
      fetchCates: 'FETCH_CATES'
    })
  },
  computed: {
    // ...mapState('cart', ['num']),
    ...mapState({
      cartNum: state => state.cart.num,
      userNum: state => state.user.num
    }),
    // ...mapGetters('cart', ['DOUBLE_NUM'])
    ...mapGetters('cart', {
      aa: 'DOUBLE_NUM'
    })
  }
}
</script>

<style lang="scss" scoped>

</style>
